from rest_framework.response import Response
from rest_framework.viewsets import ModelViewSet

from goods.models import SPUSpecification, SPU
from meiduo_admin.serialziers.specs import SpecsSerialzier, SPUSerialzier
from meiduo_admin.utils import PageNum

'''
商品规格的增删改查
'''
class SpecsView(ModelViewSet):
    #指定查询集
    queryset = SPUSpecification.objects.all()
    #指定序列化器
    serializer_class = SpecsSerialzier
    #指定分页器
    pagination_class=PageNum

    #获取SPU商品
    def simple(self,request):
        spus=SPU.objects.all()
        ser=SPUSerialzier(spus,many=True)
        return Response(ser.data)




